<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>异常处理列表</title>
    <!--1.引入bootstrap样式框架；-->
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">

    <!--2.引入angularJS分页样式的框架；-->
    <link rel="stylesheet" href="../angularjs/pagination.css">

    <!--3.引入bootstrap中的Jquery框架；-->
    <script src="../bootstrap/js/jquery.min.js"></script>
    <!--4.引入bootstrap中的Js框架；-->
    <script src="../bootstrap/js/bootstrap.min.js"></script>

    <!--5.引入AngularJS的JS框架-->
    <script src="../angularjs/angular.min.js"></script>

    <!--6.引入AngularJS分布的JS框架-->
    <script src="../angularjs/pagination.js"></script>
    <!--7.自己写代码-->
    <script>
        var app = angular.module("problemApp", ['pagination']); //定义一个模块;myApp
        app.controller("problemController", function ($scope, $http) { //$http定义一个接口!
            // 分页配置
            $scope.paginationConf = {
                currentPage: 1, //当前页 ;
                itemsPerPage: 5, //每页五条 ;
                totalItems: 10, //共计多少条数据;
                perPageOption: [2, 5, 10, 20],
                onChange: function () {
                    //每次改变页面大小,自动调用;
                    $scope.look();
                }
            };
            // $scope.getAllByPages = function () {
            //     $http.get("/problem/getAllQuestion?index=" + $scope.paginationConf.currentPage +
            //         "&size=" + $scope.paginationConf.itemsPerPage).success(function (data) {
            //         $scope.list = data.rows;
            //         $scope.paginationConf.totalItems = data.total;
            //     });
            // };

            //zuul
            $http.post('http://localhost:12000/tran/ip').then(function (data) {  //正确请求成功时处理
                console.log(data)
                if (data.data.code == 403) {
                    window.location.href = "/login.html";
                }
            }).catch(function (result) { //捕捉错误处理
                console.info(result);
            });

            $scope.change = function (pkKid) {
                window.sessionStorage.setItem("pkKid",pkKid);
                window.location.href = "answer.html"
            };
            $scope.question = "";
            $scope.look = function () {
                $http.post("http://localhost:12000/user/problem/getQuestion?index=" + $scope.paginationConf.currentPage +
                    "&size=" + $scope.paginationConf.itemsPerPage +
                    "&question="+$scope.question).success(function (data) {
                    $scope.list = data.rows;
                    $scope.paginationConf.totalItems = data.total;
                    console.log(data)
                })
            }
        });
    </script>
</head>
<body ng-app="problemApp" ng-controller="problemController">
<div>
    <ol class="breadcrumb" style="margin-top: 0px;margin-bottom: 0;">
        <li><a >Home</a></li>
        <li><a >银行</a></li>
        <li><a href="/index.html">返回首页</a></li>
    </ol>
</div>
<div class="container">
    <div class="panel panel-primary">
        <h1>异常处理列表</h1>
        <div class="panel-body">
            
            <div>
                <input type="text" ng-model="question" >
                <a class="btn btn-success" type="button" ng-click="look()">查询</a>
            </div>
            
            <table class="table table-condensed table-striped table-bordered table-hover text-center">
                <tr>
                    <td>编号</td>
                    <td>选择异常</td>
                    <td>操作</td>
                </tr>
                <tr ng-repeat="p in list">
                    <td>{{$index+1}}</td>
                    <td>{{p.ukKname}}</td>
                    <td>
                        <a ng-click="change(p.pkKid)" class="btn btn-success">查看</a>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <!--分页-->
                        <tm-pagination conf="paginationConf"></tm-pagination>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
</body>
</html>